package at.ac.tuwien.ifs.calendit.basis.gui;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import at.ac.tuwien.ifs.calendit.basis.helper.Constants;
import at.ac.tuwien.ifs.calendit.dao.IRaum;
import at.ac.tuwien.ifs.calendit.dao.ITermin;
import at.ac.tuwien.ifs.calendit.domain.Raum;

public class RaumverwaltungLogic {
	private static Log log = LogFactory.getLog(BenutzerverwaltungLogic.class);
	private IRaum ra;
	private ITermin termin;

	/**
	 * The XML Bean Factory from Spring.
	 */
	private XmlBeanFactory xbf;
	
	public RaumverwaltungLogic(){
		ClassPathResource res = new ClassPathResource(Constants.SPRINGBEANS);
		xbf = new XmlBeanFactory(res);
		ra = (IRaum) xbf.getBean("RaumDAO");
		termin = (ITermin) xbf.getBean("TerminDAO");
	}
	public Raum save(String name,String lage,int kapaz) {
		
		
		Raum r = new Raum();
		//r.setRaumID(raumID);
		r.setRaumname(name);
		r.setLage(lage);
		r.setKapazitaet(kapaz);
		log.info("LogicSave");
		log.info(r);
		return ra.add(r);
		
	}

	public Raum update(int editID, String name,String lage,int kapaz) {
		Raum r = new Raum();
		r.setRaumID(editID);
		r.setRaumname(name);
		r.setLage(lage);
		r.setKapazitaet(kapaz);
		log.info("LogicUpdate");
		return ra.update(r);
	}

	public boolean delete(int raumID) {
		log.info("LogicDelete");
		return ra.delete(raumID);
		
	}

}
